package org.sunrise.game.common.message;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.sunrise.game.common.network.message.BaseMessage;
import org.sunrise.game.common.utils.IdGenerator;

/**
 * 对外服和game通信的数据结构
 */
@Getter
@ToString(callSuper = true)
public class GameMessage extends BaseMessage {
    private long connectionId; // 对外服分配的客户端连接id
    private int gameId; // 客户端所连接的gameId
    private byte[] bytes; // 客户端和game实际通信的字节数据
    @Setter
    private int from; // 消息来源，区分game和client

    public GameMessage() {

    }

    public GameMessage(long connectionId, int gameId, byte[] bytes) {
        this.connectionId = connectionId;
        this.gameId = gameId;
        this.bytes = bytes;
        this.setMessageId(IdGenerator.getId());
    }

    public GameMessage(long connectionId, int gameId, long messageId, byte[] bytes, int from) {
        this.connectionId = connectionId;
        this.gameId = gameId;
        this.from = from;
        this.setMessageId(messageId);
        this.bytes = bytes;
    }
}

